<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page contentType="text/html; charset=ISO8859_1" pageEncoding="ISO8859_1"%>
<%@ page errorPage="error.jsp" %>

<html>
<head>
<title>Car Rent 1.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO8859_1">

<style type="text/css">
body,table,hr {
	color: black;
	background: silver;
	font-family: Verdana, sans-serif;
	font-size: x-small;
}
</style>

</head>
<body>
	<h2>Car Rent 1.0</h2>
	<fieldset>
		<form method="post" action="language?lang=en">
			<input type="submit" name="login" value="en">
		</form>
		<form method="post" action="language?lang=ru">
			<input type="submit" name="login" value="ru">
		</form>
	</fieldset>


	<jsp:useBean id="lang" class="com.epam.rentcar.utils.Language" />
	<fmt:setBundle basename="${lang.getLanguage()}" />



	<c:set var="user" value="${sessionScope.user}" />
	<c:choose>
		<c:when test="${user == null}">
			<fmt:message key="not_loggedin" />
		</c:when>
		<c:otherwise>
			<fmt:message key="logged_as" />
			<c:out
				value="${sessionScope.user.getRole()} ${sessionScope.user.getLogin()}" />
		</c:otherwise>

	</c:choose>
	<fieldset>
		<legend>
			<b>Car Rent 1.0</b>
		</legend>
		<c:choose>
			<c:when test="${user == null}">
				<a href="login.jsp"><fmt:message key="login" /></a>
				<br>
				<a href="register.jsp"><fmt:message key="register" /></a>
				<br>
			</c:when>
			<c:otherwise>
				<a href="logoutAction.perform"><fmt:message key="logout" /></a>
				<br>
				<c:if test="${user.getRole() == 'user'}">
					<a href="userPage.jsp"><fmt:message key="user_page" /></a>
					<br>
					<a href="requestCarAction.perform"><fmt:message
							key="request_a_car" /></a>
					<br>
				</c:if>
				<c:if test="${user.getRole() == 'admin'}">
					<a href="adminPage.jsp"><c:out
							value="${sessionScope.user.getLogin()} ${sessionScope.user.getRole()} page" />
					</a>
					<br>
				</c:if>
			</c:otherwise>
		</c:choose>
	</fieldset>	
</body>
</html>